local zhenglun = fk.CreateSkill{
    name = "wk_heg__zhenglun",
}

Fk:loadTranslationTable{
    ["wk_heg__zhenglun"] = "整论",
    [":wk_heg__zhenglun"] = "准备阶段，你可摸一张牌，然后若你手牌数大于存活角色数或其中包含四种花色，则你展示所有手牌并弃置手牌中数量最多的一种花色的所有牌，否则你重复此流程。",

    ["#wk_heg__zhenglun-discard"] = "整论：弃置手牌中数量最多的一种花色的所有牌",

    ["$wk_heg__zhenglun1"] = "遗失礼仪，则具非议。",
    ["$wk_heg__zhenglun2"] = "行遗礼之举，于不敬王者。",
}

zhenglun:addEffect(fk.EventPhaseStart,{
    anim_type = "special",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(zhenglun.name) and player.phase == Player.Start
      end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(1, zhenglun.name)
        player:showCards(player:getCardIds(Player.Hand))
        while true do
          local cards = player.player_cards[Player.Hand]
          local suits = {}
          for _, id in ipairs(cards) do
            local suit = Fk:getCardById(id).suit
            if suit ~= Card.NoSuit then
              table.insertIfNeed(suits, suit)
            end
          end
          if player:getHandcardNum() > #room.alive_players or #suits == 4 then
            room:delay(1000)
            player:showCards(cards) -- 睿智
            break
          else
            room:delay(500)
            player:drawCards(1, zhenglun.name)
          end
        end
        local suitMapper = { [1] = {}, [2] = {}, [3] = {}, [4] = {} }
        table.forEach(player:getCardIds(Player.Hand), function(id)
          if Fk:getCardById(id).suit ~= Card.NoSuit then
            table.insert(suitMapper[Fk:getCardById(id).suit], id)
          end
        end)
        local maxNum = -1
        local all_suits = {"log_spade", "log_club", "log_heart", "log_diamond"}
        local choices = {}
        for i, j in ipairs(suitMapper) do
          local num = #j
          if num >= maxNum then
            if num > maxNum then
              maxNum = num
              choices = {}
            end
            table.insert(choices, all_suits[i])
          end
        end
        local choice = room:askToChoice(player, {choices = choices, skill_name = zhenglun.name, prompt = "#wk_heg__zhenglun-discard"})
        local cid = suitMapper[table.indexOf(all_suits, choice)]
        room:throwCard(cid, zhenglun.name, player, player)
      end,
})

return zhenglun